/*-------------------------------------------------------- 
* Module Name : OLMenuSurface
* Version : 1.0
* 
* Software Name : Qt App Template
* Version : 1.0
*
* Copyright � 2010 � 2011 France T�l�com
* This software is distributed under the LGPL v2.1 license,
* the text of which is available at http://www.gnu.org/licenses/lgpl-2.1.html
* or see the "LICENSE.txt" file for more details.
*
*--------------------------------------------------------
* File Name   : OLMenuSurface.h
*
* Created     : 07 June 2011
* Author(s)   : Omer Saleem
*
* Description :
* The modal background surface for the menu panel (OLMenuPanel)
* to be rendered on.
*
*--------------------------------------------------------
* 1.0 - First open source release
*
*/

#ifndef OLMENUSURFACE_H
#define OLMENUSURFACE_H

#include <QWidget>
#include <QSignalMapper>
#include <QAbstractAnimation>

#include "OLModalBackground.h"

class OLMenuPane;
class QParallelAnimationGroup;

class OLMenuSurface : public OLModalBackground
{
    Q_OBJECT

public:
    enum OLMenuState
    {
        NoMenu = 0,
        MenuAvailable,
        MenuRequested,
        MenuDisplayed,
        MenuDismissed
    };

public:
    explicit OLMenuSurface(QWidget *parent = 0);

    int addMenuItem(const QString& menuitem, const QObject* receiver=0, const char* method=0);
    void addMenuItem(int id, const QString& menuitem, const QObject* receiver=0, const char* method=0);
    void removeMenuItem(int id);
    void hideMenuItem(int id);
    void showMenuItem(int id);

public slots:
    void showMenu();
    void hideMenu();

private slots:
    void handleAnimFinished();
    void menuItemClicked(int id);
    void handleAppSize();

signals:
    void menuStateChange(OLMenuSurface::OLMenuState state);
    void portraitSwitch();
    void landscapeSwitch();

protected:
    void resizeEvent(QResizeEvent * event);

private:
    void changeState(OLMenuState newstate);

private:
    OLMenuState m_state;
    QSignalMapper* m_mapper;
    OLMenuPane* m_menupane;
    QParallelAnimationGroup* m_animGroup;
};

#endif // OLMENUSURFACE_H
